home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Softwarová Záchrana 3
/
Softwarova-zachrana-3.bin
/
TextHarvest
/
TextHarvest-Install.exe
/
{app}
/
ScriptSample03.txt
< prev
next >
Wrap
Text File
|
2004-12-02
|
5KB
|
97 lines
;---------------------------------------------------------------------------
; Sample Parse-O-Matic Script for TextHarvest
;---------------------------------------------------------------------------
;
; This script processes the input file InputSample01.txt, which is a
; report of items sold. (If you view the input file in the file viewer,
; you will have to set the display width to 150 to see the lines without
; their getting line-wrapped.)
;
;---------------------------------------------------------------------------
; Check settings. Please see the script file ScriptSample01.txt if you do
; not understand how this section works; the techniques are explained there.
;---------------------------------------------------------------------------
Begin FirstLine = ''
FirstLine = 'N'
InputFileWanted = 'InputSample01.txt'
X = Len $OptionX $OptionY $OptionZ
Begin X <> 0
M1 = 'Please clear the /Keep /Delete and' $0A$0D
M2 = '/Control input boxes and try this' $0A$0D
M3 = 'this script again.'
Stop M1 M2 M3
End
Begin $ActualIFN ~ InputFileWanted
M1 = 'Please try this script with the' $0A$0D
M2 = 'input file ' InputFileWanted
Stop M1 M2
End
;
; Output header
;
SepLine = Padded '' 80 'Left' '-'
OutEnd SepLine
X = 'Number of Items Sold to Each Customer'
X = Padded X 80 'Center'
OutEnd X
OutEnd SepLine
;
; Output the date (which is on the first line of the input file)
;
Date = $OutData[7 17]
OutNull ; Skip a line
X = Padded Date 80 'Center' ; Center the date
OutEnd X ; Output the date
Done ; Skip the rest of the script
End
;---------------------------------------------------------------------------
; Detect customer information line. We do this by looking for a digit in
; column 8. The customer information line is the only line that has a digit
; there.
;---------------------------------------------------------------------------
Begin '0123456789' ^ $OutData[8] ; Look for the digit
CustName = $OutData[17 47] ; Get the name
TrimChar CustName ; Remove the extra spaces
CustName = ChangeCase CustName 'HardCaps' ; Convert To Capital Letters
Change CustName '''S' '''s' ; Fix case on possessives
X = Len CustName ; Find out how long it is
SepLine = Padded '' X 'Left' '-' ; A line as long as the name
SepLine = Padded SepLine 80 'Center' ; Center the line
CustName = Padded CustName 80 'Center' ; Center customer name
OutNull ; Skip a line
OutEnd SepLine ; Output the separator line
OutEnd CustName ; Output customer name
OutEnd SepLine ; Output the separator line
OutNull ; Skip a line
Done ; Skip the rest of the script
End
;---------------------------------------------------------------------------
; Detect the first line of the product information. We can recognize these
; because they always has a product code with the pattern AAA-NN-AAA (for
; example, ABC-12-XYZ) in columns 10 to 19.
;---------------------------------------------------------------------------
TestCode = $OutData[10 19] ; Get what might be the code
KeepChar TestCode '/AZ/09/-' ; Remove any non-code characters
ProdLine1 = 'Yes' ; Assume it's good for a moment
If TestCode[4] <> '-' ProdLine1 = '' ; We should have a dash in col 4
If TestCode[7] <> '-' ProdLine1 = '' ; We should have a dash in col 7
Begin ProdLine1 = 'Yes'
ProdLine1 = '' ; Reset this back to null
NumberSold = $OutData[55 58] ; Get number of units sold
ProdLine2 = 'Yes' ; Set up for next line of data
Done ; Skip the rest of the script
End
;---------------------------------------------------------------------------
; If ProdLine2 = 'Y' it means that the previous line of data was the first
; line of product information.
;---------------------------------------------------------------------------
Begin ProdLine2 = 'Yes'
ProdLine2 = '' ; Reset this back to null
Product = $OutData[10 40] ; Get product name
Product = Padded Product 54 'Left' ; Put some spaces on the left
OutEnd Product NumberSold ; Output product and number sold
End